<template>
	<view class="content">
		<view class="dl">
			登录微课课堂
		</view>
		<view class="loginbutton" @click="wxlogin()">
			微信登录
		</view>
	</view>
</template>

<script setup>
	import {
		onMounted
	} from "vue"
	import
	instance
	from "../../request.js"
	const wxlogin = () => {
		uni.login({
			success: async (res) => {
				console.log(res)
				const ress = await instance.get(`/api/ucenter/webChat/callback?code=${res.code}`);
				console.log(ress)
				if(ress.code == 200){
					uni.setStorageSync("token",ress.data.token)
					// uni.switchTab({
					// 	url:"/pages/my/my"
					// })
					uni.navigateBack()
				}
			}
		})
	}
</script>

<style>
	.content {
		width: 100%;
		height: 100%;
		padding: 20rpx;
		box-sizing: border-box;

	}

	.dl {
		text-align: center;
		margin-top: 80rpx;
	}

	.loginbutton {
		padding: 20rpx 0px;
		box-sizing: border-box;
		text-align: center;
		margin-top: 80rpx;
		background-color: #4db5fb;
		color: #fff;
		border-radius: 100rpx;
	}
</style>